<template>
  <view>
    <view class="colorB" style="padding:30rpx;" v-for="(item ,index) in simList" :index="index" :key="index">
      <view class="mainColor border-10" style="border: 1px solid #fff;">
        <view class="padding-10">
          ICCID：{{item.iccId}}
        </view>
        <view class="padding-10">套餐名称：{{item.name || '一'}}</view>
        <view class="text padding-10">对应桩号：{{item.pileSn || '一'}}</view>
        <view class=" padding-10">sim卡商：：{{simSupp(item.simSupplier) }}</view>
        <view class=" padding-10">状态：{{simStatus(item.simCardStatus) }}</view>
        <view class="text padding-10">套餐总流量：{{item.totalData || '一'}}</view>
        <view class="text padding-10">剩余流量：{{item.surplusData || '一'}}</view>
        <view class="text padding-10">到期时间：{{item.expireTime || '一'}}</view>
        <view class="text padding-10">剩余天数：{{item.remainingDays}}</view>


        <view class=" padding-10">SIM卡运营商：{{simOperator(item.operator) }}</view>
        <!-- <view class="text padding-10">操作：
          <text style="color: aqua;margin-right: 20rpx;" v-if="checkPermi(['pile:sim:edit'])">续费</text>
          <text style="color: aqua;" v-if="checkPermi(['pile:sim:remove'])">删除</text>
        </view> -->
        <!-- <view class="text padding-10">微信商户订单号：{{item.outTradeNo === null ? '一':item.outTradeNo}}</view> -->
      </view>
    </view>

    <!-- 分页 -->
    <uni-pagination show-icon :page-size="queryParams.pageSize" :current="queryParams.pageNum" :total="total"
      @change="change" />
    <view class="btn-view;mainColor border-10">
      <view class="">
        <text
          class="example-info">当前页：{{ queryParams.pageNum }}，数据总量：{{ total }}条，每页数据：{{ queryParams.pageSize }}</text>
      </view>
      <view class="btn-flex ">
        <button class="button word-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70"
          @click="add"><text class="word-btn-white">增加10条数据</text></button>
        <button class="button" type="default" @click="reset" style="margin-left: 40rpx;">重置数据</button>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    checkPermi,
    checkRole
  } from "@/utils/permission";
  import {
    getSimInfo
  } from '@/api/pile/sim'
  import {
    simSupp,
    simOperator,
    simStatus
  } from '@/common/dict.js'
  export default {
    props: ['stationId'],
    data() {
      return {
        simSuppList: [],
        simOperatorList: [],
        simStatusList: [],
        // 总条数
        total: 0,
        // 订单表格数据
        simList: [],
        // 订单详情表格数据
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          name: null,
          iccId: null,
          status: null,
          totalData: null,
          surplusData: null,
          expireTime: null,
          operator: null,
          pileSn: null,
          simSupplier: null,
        },
      };
    },
    methods: {
      checkPermi,
      checkRole,
      add() {
        this.queryParams.pageSize += 10
        this.getList();
      },
      reset() {
        this.queryParams.pageSize = 10
        this.queryParams.pageNum = 1
        this.getList();
      },
      change(e) {
        console.log(e.current);
        this.queryParams.pageNum = e.current
        this.getList()
      },
      simOperator(sim) {
        simOperator.then(result => {
          this.simOperatorList = result
        })
        let str = this.simOperatorList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      simStatus(sim) {
        simStatus.then(result => {
          this.simStatusList = result
        })
        let str = this.simStatusList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      simSupp(sim) {
        simSupp.then(result => {
          this.simSuppList = result
        })
        let str = this.simSuppList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      getList() {
        getSimInfo(this.queryParams).then(response => {
          this.simList = response.rows;
          // console.log('this.simList', this.simList)
          this.total = response.total;
        });
      },
    },
    created() {
      this.getList()
    }
  }
</script>

<style lang="scss">

</style>